/*
 * @Author: WangShuai 1830773767@qq.com
 * @Date: 2023-12-03 17:36:30
 * @LastEditors: WangShuai 1830773767@qq.com
 * @LastEditTime: 2025-06-18 16:07:34
 * @FilePath: \vue3_admin_template\project\src\components\index.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { Component } from 'vue'
//引入Svg图片并注册成全局组件
import SvgIcon from './SvgIcon/index.vue'
//引入分页器组件并注册成全局组件
import PageNation from './PageNation/index.vue'
//引入Element图标
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
// console.log("引入Element图标",ElementPlusIconsVue)
//引入分类组件
import Category from '@/components/Category/index.vue'
//引入表格组件
import Table from '@/components/Table/index.vue'
// 定义组件类型
type GlobalComponents = {
  [key: string]: Component // Vue 的 Component 类型
}
//定义一个全局对象
const allGloablComponent: GlobalComponents = {
  SvgIcon,
  PageNation,
  Category,
  Table,
}
// console.log("Object.keys(allGloablComponent)",Object.keys(allGloablComponent))

export default {
  //插件函数务必叫install方法
  install(app: any) {
    //注册项目全部全局组件
    Object.keys(allGloablComponent).forEach((key) => {
      //注册全局组件
      app.component(key, allGloablComponent[key]) //app.component(key,allGloablComponent as any[key])
      //将Element-Plus图标注册为全局组件
      // console.log("11111111",Object.entries(ElementPlusIconsVue))
      for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
        app.component(key, component)
      }
    })
  },
}
